package com.chaoyong.higo.activity;

import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebSettings;
import android.webkit.WebSettings.LayoutAlgorithm;
import android.webkit.WebView;
import android.widget.ImageButton;

import com.chaoyong.higo.R;
import com.chaoyong.higo.base.BaseActivity;
import com.chaoyong.higo.utils.V;
import com.chaoyong.higo.view.TitleView;

public class ImagDetailActivity extends BaseActivity {
	@Override
	public int layoutResID() {
		return R.layout.activity_imag_detail;
	}
	private TitleView imagdet_title;
	private Context context;
	private ImageButton imagedet_imgbt;
	private WebView imagdet_webView;
	private String detail;
	@Override
	public void findView() {
		imagdet_title=V.f(this,R.id.imagdet_title);
		imagdet_webView=V.f(this, R.id.imagdet_webView);
	}

	@SuppressWarnings("deprecation")
	@Override
	public void init() {
		context=this;
		detail=getIntent().getStringExtra("info");
		imagdet_title.setTitleText("图文详情", context.getResources().getColor(R.color.home_text));
		imagdet_title.setLeftImage(R.drawable.back_red);
		imagdet_title.setonLeftClinck(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finish();
			}
		});
		
		/*WebSettings webSettings = imagdet_webView.getSettings();  
        webSettings.setSupportZoom(true);  
        webSettings.setJavaScriptEnabled(true);  
        
        webSettings.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
		webSettings.setDisplayZoomControls(true);
        
        webSettings.setJavaScriptCanOpenWindowsAutomatically(true);  
        webSettings.setBuiltInZoomControls(true);*/
		
        WebSettings webSettings = imagdet_webView.getSettings();  
       /* webSettings.setSupportZoom(true);  
        webSettings.setJavaScriptEnabled(true);  
        
       // webSettings.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
		webSettings.setDisplayZoomControls(true);
        
        webSettings.setJavaScriptCanOpenWindowsAutomatically(true);  
        webSettings.setBuiltInZoomControls(true);*/
        
        
        
      //支持javascript
        webSettings.setJavaScriptEnabled(true); 
        // 设置可以支持缩放 
        webSettings.setSupportZoom(true); 
        // 设置出现缩放工具 
       // webSettings.setBuiltInZoomControls(true);
        //扩大比例的缩放
        webSettings.setUseWideViewPort(true);
        //自适应屏幕
        webSettings.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
        webSettings.setLoadWithOverviewMode(true);
        
        webSettings.setJavaScriptCanOpenWindowsAutomatically(true);  
        //设置这个才能放大缩小！
        webSettings.setBuiltInZoomControls(true);
        //设置false右下角的放大缩小图标会隐藏掉。
        webSettings.setDisplayZoomControls(false);
        
        //imagdet_webView.loadData(detail,"text/html;charset=UTF-8", null);
        imagdet_webView.loadDataWithBaseURL(null, detail, "text/html", "utf-8", null);
        
		
		/*WebSettings webSettings = imagdet_webView.getSettings();
		webSettings.setSavePassword(false);
		webSettings.setSaveFormData(false);
		webSettings.setDefaultTextEncodingName("UTF-8");
		webSettings.setSupportZoom(true);
		webSettings.setJavaScriptEnabled(true);
		webSettings.setDefaultFontSize(14);
		webSettings.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);*/ // 图片大小
		
		/*String web="<!DOCTYPE html><html><head>"
				+ "<meta name="+"\""+"viewport"+"\"content="+"\""+"width=device-width"+"\""+"/>"
						+ "<title>一元云筹</title>"
						+ "<style>"
						+ "img{"
						+ "max-width:95%;"
						+ "width:95%;"
						+ "height:100%;"
						+ "}"
						+ "</style>"
								+ "</head><body>";
		String wei="</body></html>";
		web+=detail;
		web+=wei;
		imagdet_webView.loadDataWithBaseURL(null,web
				.replace("&lt;", "<").replace("&gt;", "/>")
				.replace("&amp;", "&"), "text/html","UTF-8", null);*/
	}
	
	@Override
	public void onClick(View v) {
		
	}

}
